#include <iostream>
#include <string>
#include <vector>

bool chk_prime(int n) {
    if (n > 1) {
        for (int i = 2; i <= n / 2; i++) {
            if (n % i == 0) {
                return false;
                break;
            }
        }
        return true;
    } else {
        return false;
    }
}

int main() {
    std::string n;
    std::getline(std::cin, n);
    std::vector<std::string> digit = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    std::string ch = "";
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < digit.size(); j++) {
            if (n.substr(i, 1) == digit[j]) {
                ch += std::to_string(j);
                break;
            }
        }
    }
    if (ch[0] == '0' || ch.length() != 3) {
        std::cout << "Wrong input" << std::endl;
    } else {
        int num = std::stoi(ch);
        if (chk_prime(num)) {
            std::cout << num << std::endl;
        } else {
            int count = 1;
            while (count < num) {
                int p1 = num - count;
                int p2 = num + count;
                if (chk_prime(p1) && chk_prime(p2)) {
                    std::cout << p1 << " " << p2 << std::endl;
                    break;
                } else if (chk_prime(p1) && !chk_prime(p2)) {
                    std::cout << p1 << std::endl;
                    break;
                } else if (!chk_prime(p1) && chk_prime(p2)) {
                    std::cout << p2 << std::endl;
                    break;
                } else {
                    count++;
                }
            }
        }
    }
    return 0;
}


